﻿/*
{
"状态":1,
"名称":"发布-朋友圈",
"作者":"马学兵",
"创建时间":"2018-07-28",
"功能":"发布-朋友圈",
"log": [
	{"date":"06-01" , "dev" :"hzhh" , "content" : ""}
]
}
*/


DECLARE @minid INT
DECLARE @rowcnt INT

set @minid='{minid}'

IF ISNULL(@minid,0)=0
BEGIN
	SELECT @minid=MAX(wechat_share_key)+1 FROM k_wechat_share
END  

SELECT TOP 10 * into #Tmp FROM k_wechat_share
WHERE wechat_share_key<@minid
ORDER BY wechat_share_key DESC


SELECT wechat_share_key,title,content,words,type,CONVERT(VARCHAR(10),create_time,121) as create_time FROM #Tmp order by wechat_share_key desc

SELECT * FROM 
(
SELECT wechat_share_key,url1,url2,url3,url4,url5,url6,url7,url8,url9 FROM #Tmp
) A
UNPIVOT
(
	url FOR field IN(url1,url2,url3,url4,url5,url6,url7,url8,url9)
)U 
WHERE ISNULL(U.url,'')<>''

drop table #Tmp